﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;


using TFSClient = Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Server;

using LeMigue.Scrum.Iterface.Service;
using LeMigue.Scrum.Iterface.Model;

using LeMigue.Framework.Utils;

namespace LeMigue.Scrum.TfsScrumV1.Service
{

    public class TeamProjectService : AbstractTfsService, ITeamService
    {


        public IList<Team> List()
        {
            IList<Team> projetos = new List<Team>();

            foreach (TFSClient.Project projeto in TeamProjets)
            {
                projetos.Add(new Team(projeto.Id, projeto.Name));
            }
            return projetos;
        }

        public Team Load(int id)
        {
            //TODO: utilizar o novo objeto
            /*Team team = Cache.Get<Team>(UserPrincipal.Current.Sid.ToString(), "Team");

            if (team != null && team.Id == id)
                return team;

            Cache.Remove(UserPrincipal.Current.Sid.ToString(), "Team");
            

            TFSClient.Project projeto = TeamProjeto(id);
            team = new Team(projeto.Id, projeto.Name);

            Cache.Set<Team>(UserPrincipal.Current.Sid.ToString(), "Team", team);

            return team;*/

            TFSClient.Project projeto = TeamProjeto(id);
            Team team = new Team(projeto.Id, projeto.Name);

            return team;
        }

        public Team Save(Team item)
        {
            //TODO: pensar em um tratamento para este cara
            throw new NotImplementedException();
        }

        
    }
}
